Hi Tracker team,
I'm searching for a possibility to print selected layers (ocgs) of a pdf file to a new pdf document containing only the layer information with the same size and rotation of the original document. The exported pdf layer file should be also transparent in order to overlay it into another pdf document or the original pdf document at some later time.
I'm able to export a selected layer (by hiding the other once) into a png file format and it is no problem to reimport the exported picture file with same size and transparence. But I don't want to rasterize the ocg layer information in order to keep text information available.
Is this possible using the pdf-xchange drivers api sdk (or any other api of your products)?
Thank you for your help!
Cheers,
Martin
Print selected layers
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: Print selected layers
Hi Martin,
I suspect you are hiding the unwanted layers with the JS discussed here:
https://forum.pdf-xchange.com/ ... 36&t=16158
So you can also try to print from the Viewer AX to our printing drivers after the unwanted layers are hidden.
There's a big chance that some fonts would be printed as curves, but at least nothing will be rasterized, and as long as there's no background layer in your PDF - the resulting one would also be with transparent background and can be used for e.g. overlaying other files.
Best,
Stefan
I suspect you are hiding the unwanted layers with the JS discussed here:
https://forum.pdf-xchange.com/ ... 36&t=16158
So you can also try to print from the Viewer AX to our printing drivers after the unwanted layers are hidden.
There's a big chance that some fonts would be printed as curves, but at least nothing will be rasterized, and as long as there's no background layer in your PDF - the resulting one would also be with transparent background and can be used for e.g. overlaying other files.
Best,
Stefan
-
- User
- Posts: 153
- Joined: Thu Apr 07, 2011 10:01 am
Re: Print selected layers
Hi Stefan,
you'r exactly right. I'm trying to use the ToggleOCGsForDoc snippet of Vasyl using the PDF-XChange Viewer SDK. What I do is opening the pdf document with OpenDocument method. Then I call the RunJavaScript method to execute the js code to hide the layer(s).
But how can I print the displayed / opened pdf document with the PDF X-Change printer driver? Do I have to use the viewer sdk or the drivers api. As far as I know I do only have a method called 'printdocument' within the viewer sdk. But before printing I'd like to set up the paper size which I couln't get managed to a custom paper size.
Could you give me an idea how to use your products / code to accomplish my needs?
Thank's a lot for your great work and support!!!
Cheers
Martin
you'r exactly right. I'm trying to use the ToggleOCGsForDoc snippet of Vasyl using the PDF-XChange Viewer SDK. What I do is opening the pdf document with OpenDocument method. Then I call the RunJavaScript method to execute the js code to hide the layer(s).
But how can I print the displayed / opened pdf document with the PDF X-Change printer driver? Do I have to use the viewer sdk or the drivers api. As far as I know I do only have a method called 'printdocument' within the viewer sdk. But before printing I'd like to set up the paper size which I couln't get managed to a custom paper size.
Could you give me an idea how to use your products / code to accomplish my needs?
Thank's a lot for your great work and support!!!
Cheers
Martin
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: Print selected layers
Hi Martin,
You will need both the Viewer and the Driver.
In the Viewer you first hide the unwanted layers in the document using the JS code, then print the file using:
PrintDocument(nDocumentID, PXCVA_Flags.PXCVA_NoUI);
Before calling the PrintDocument method in the Viewer you should have set up an instance of the printing driver and made it the default printer and specified all the required options as paper size, image compression etc.
Please check the relative sample project and help files for both.
Best,
Stefan
You will need both the Viewer and the Driver.
In the Viewer you first hide the unwanted layers in the document using the JS code, then print the file using:
PrintDocument(nDocumentID, PXCVA_Flags.PXCVA_NoUI);
Before calling the PrintDocument method in the Viewer you should have set up an instance of the printing driver and made it the default printer and specified all the required options as paper size, image compression etc.
Please check the relative sample project and help files for both.
Best,
Stefan
-
- User
- Posts: 153
- Joined: Thu Apr 07, 2011 10:01 am
Re: Print selected layers
Hi Stefan,
I had a look at your suggestions and got it managed to print out the selected layer with the same paper & sheet size of the original document. But for some reasons the object(s) of the selected layer are not at the same position like it is in the original pdf document. It looks like the printed layers gets some sort of scaling. The objects of the layer (pdf) document are a little bit shifted.
Here's the code I'm using:
I might miss a directive which sets the correct paper scaling but I can't find the right option. At the moment we are using an evaluation version of the drivers api and the exported layer pdf documents gets a watermark from your programming. Does this could be the reason for shift?
I hope you can give me an advice.
Thank you!
Best,
Martin
I had a look at your suggestions and got it managed to print out the selected layer with the same paper & sheet size of the original document. But for some reasons the object(s) of the selected layer are not at the same position like it is in the original pdf document. It looks like the printed layers gets some sort of scaling. The objects of the layer (pdf) document are a little bit shifted.
Here's the code I'm using:
Code: Select all
int iActiveDocID = 0;
try
{
// open document
axCoPDFXCview1.OpenDocument(TBSourceFileName.Text, null, out iActiveDocID, 0);
// hide layers except the selected layer
string sResult = "";
axCoPDFXCview1.RunJavaScript(tbJavaScript.Text, out sResult, 0, 0);
// set printer and printer settings
PXCComLib.CPXCControlEx prnFactory = new PXCComLib.CPXCControlEx();
PXCComLib.CPXCPrinter PDFPrinter = (PXCComLib.CPXCPrinter)prnFactory.get_Printer("", "PDF-XChange 4.0", "<REG CODE>", "<DEV CODE>");
PDFPrinter.SetAsDefaultPrinter();
PDFPrinter.Option["Paper.SheetWidth"] = 6200;
PDFPrinter.Option["Paper.SheetHeight"] = 10000;
//PDFPrinter.Option["DevMode.CWidth"] = 6200;
//PDFPrinter.Option["DevMode.CHeight"] = 10000;
PDFPrinter.Option["Save.ShowSaveDialog"] = false;
PDFPrinter.Option["Paper.SheetSizeIndex"] = -2;
PDFPrinter.Option["Save.SaveType"] = 2;
PDFPrinter.Option["Save.File"] = "D:\\IM\\layer.pdf";
PDFPrinter.Option["Save.WhenExists"] = 1;
PDFPrinter.Option["Overlay.Enabled"] = true;
//PDFPrinter.Option["Optimization.UseTransparency"] = true;
PDFPrinter.ApplyOptions(0);
axCoPDFXCview1.SetProperty("Print.ScaleType", 0);
axCoPDFXCview1.SetProperty("Print.PaperHeight", 10000);
axCoPDFXCview1.SetProperty("Print.PaperWidth", 6200);
// print document
axCoPDFXCview1.PrintDocument(iActiveDocID, (int)PXCVA_Flags.PXCVA_NoUI);
}
catch (Exception ex)
{
ShowErrorMessage(System.Runtime.InteropServices.Marshal.GetHRForException(ex));
}
I hope you can give me an advice.
Thank you!
Best,
Martin
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: Print selected layers
Hi Martin,
Could you estimate how much that shift and/or scaling is?
Or maybe you could provide us with a sample layered document, and the result after you print only one of those layers.
(if the files are sensitive please send them to support@pdf-xchange.com )
Best,
Stefan
Could you estimate how much that shift and/or scaling is?
Or maybe you could provide us with a sample layered document, and the result after you print only one of those layers.
(if the files are sensitive please send them to support@pdf-xchange.com )
Best,
Stefan