How to convert a colored document to a monochrome one?
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
How to convert a colored document to a monochrome one?
Hi, is it possible to convert the whole document from colored to a black-and-white one, I mean both font and images? I've found e.g. the PXC_ReduceImageColors function, which converts the image to grayscale.
Thanks for your replies!
Thanks for your replies!
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hello Relapse,
This is a PDF Tools PXCLIB40 LIB function, so you can use that only when building new PDF files, and you have posted in the Viewer SDK forums - so are you creating PDF files or do you want to render existing PDFs as images?
Best,
Stefan
This is a PDF Tools PXCLIB40 LIB function, so you can use that only when building new PDF files, and you have posted in the Viewer SDK forums - so are you creating PDF files or do you want to render existing PDFs as images?
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
I'm only interested in existing files. But did you mean it's only possible to render (export?) pdf files as images? Isn't it possible to convert an existing colored pdf file to another monochrome pdf file?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
Currently it's not possible to reprocess an existing file and just replace an image file in it without working with the low level API. Alternative solution workign with the High Level one will be to open the file - read all of it's contents reprocess all of it - including reworking the images - and then creating new PDF file from scratch that looks exactly as the original but is colorless. You will also need to process all text elements - and make sure that you discard any colour information when adding them to the new document.
And it seems this topic is for the Tools SDK - so I will move it to the correct forum.
Best,
Stefan
Currently it's not possible to reprocess an existing file and just replace an image file in it without working with the low level API. Alternative solution workign with the High Level one will be to open the file - read all of it's contents reprocess all of it - including reworking the images - and then creating new PDF file from scratch that looks exactly as the original but is colorless. You will also need to process all text elements - and make sure that you discard any colour information when adding them to the new document.
And it seems this topic is for the Tools SDK - so I will move it to the correct forum.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
It sounds rather complex, could you explain me which functions I should use for that approach?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hello Relapse,
Yes it's going to be quite complex if you go this route.
You will need to extract the text and images separately (check the 3.1.7 Image Manipulation and 3.1.10 Text Extraction sections of the PDF TOols SDK Manual) - once you have that content - you can perform the needed colour reduction operations) - you will then need to generate a new document using the PXCLIB40 LIB Functions - and then replace pages in the original document with the newly generated pages.
You will get Black and white text and images this way - but I can't guarantee that all the content will be moved - and you will also have to deal with copying annotations over - and handling their colours as well.
So if you need this monochrome document for any specific use where an image would also work - it will be much easier to directly export the page as image using e.g. the Simple Viewer DLL SDK.
Best,
Stefan
Yes it's going to be quite complex if you go this route.
You will need to extract the text and images separately (check the 3.1.7 Image Manipulation and 3.1.10 Text Extraction sections of the PDF TOols SDK Manual) - once you have that content - you can perform the needed colour reduction operations) - you will then need to generate a new document using the PXCLIB40 LIB Functions - and then replace pages in the original document with the newly generated pages.
You will get Black and white text and images this way - but I can't guarantee that all the content will be moved - and you will also have to deal with copying annotations over - and handling their colours as well.
So if you need this monochrome document for any specific use where an image would also work - it will be much easier to directly export the page as image using e.g. the Simple Viewer DLL SDK.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
I've read the documentation... The very call of PXCp_ET_AnalyzePageContent function with an example over 4 pages impressed me heavily I'd like to resume what I've understood. In order to export text to a new pdf document one needs the following calls:
- PXCp_ET_Prepare
- PXCp_ET_AnalyzePageContent
- PXC_WriteDocumentExW
- PXCp_ET_Finish
To export images to a new pdf document you need to call:
- PXCp_GetDocImageAsXCPage
- IMG_ImageCreateEmpty
- IMG_ImageInsertPage
- PXCp_SaveDocImageIntoFileW
- PXCp_ImageClearAllData
But I've found only one reference to alter the original colors: It was pSaveOptions parameter (in PXCp_SaveDocImageIntoFileW function) with the value bConvertToGray = FALSE;
Is it the right one to alter colors of the original document? I haven't found any reference to such a possibility while extracting text.
Thanks for your replies!
- PXCp_ET_Prepare
- PXCp_ET_AnalyzePageContent
- PXC_WriteDocumentExW
- PXCp_ET_Finish
To export images to a new pdf document you need to call:
- PXCp_GetDocImageAsXCPage
- IMG_ImageCreateEmpty
- IMG_ImageInsertPage
- PXCp_SaveDocImageIntoFileW
- PXCp_ImageClearAllData
But I've found only one reference to alter the original colors: It was pSaveOptions parameter (in PXCp_SaveDocImageIntoFileW function) with the value bConvertToGray = FALSE;
Is it the right one to alter colors of the original document? I haven't found any reference to such a possibility while extracting text.
Thanks for your replies!
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
While extracting the text you will get all info for it - including font and colour n PXP_TextElement structures - describing each separate text element in your processed document/page(s).
You then do process all images - export them to external format and make them monochrome (using some third party software?)
Now that you have extracted both images and text - and converted the images accordingly - you are ready to build up the new page - using the PXC_ methods and adding the text elements and monochrome images with the methods available in the PXCLIB40 LIB.
Best,
Stefan
While extracting the text you will get all info for it - including font and colour n PXP_TextElement structures - describing each separate text element in your processed document/page(s).
You then do process all images - export them to external format and make them monochrome (using some third party software?)
Now that you have extracted both images and text - and converted the images accordingly - you are ready to build up the new page - using the PXC_ methods and adding the text elements and monochrome images with the methods available in the PXCLIB40 LIB.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
So isn't there any possibility to convert the images to monochrome ones in your libraries? But I can do that with text using your software, can't I?
Should I store them as files on the disc and then place the altered ones in the new generated pdf document?You then do process all images - export them to external format
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
I just spoke with one of my colleagues - and there are a few comments he made on the page recreation method we are discussing:
- When you are extracting text and images you are doing this separately - so if there is an overlap between an image and text you will not be able to extract this information so you will not have the proper order for when recreating the document.
- If a font is embedded and there is no extended font/character info included - it might not be possible to extract all text correctly.
- vector images/objects and gradients can not be extracted.
Depending on whether or not you know what the contents of your files would be those might be irrelevant limitations, but could also be "deal breakers" if you do not know what the files will contain beforehand - e.g. if coming from external sources.
So the only plausible solution is to "reprint" a file using our Viewer SDK and the Drivers API SDK - this requires the use of two SDK products simultaneously but will be much easier to code and if you only need to get a B&W image for OCR/white space detection purposes it might be sufficient)
In the new SDK that we are developing (for v3 of the Viewer and 5 of the printing drivers) - we will be consolidating all methods - so you would be able to both make modifications to PDF content and create new PDF content working with the same file. You would be able to access a given image, extract and modify it - and then directly replace it in the existing PDF structure without the need of recreating whole pages, but I do not have the eta for the new SDK yet.
Best,
Stefan
I just spoke with one of my colleagues - and there are a few comments he made on the page recreation method we are discussing:
- When you are extracting text and images you are doing this separately - so if there is an overlap between an image and text you will not be able to extract this information so you will not have the proper order for when recreating the document.
- If a font is embedded and there is no extended font/character info included - it might not be possible to extract all text correctly.
- vector images/objects and gradients can not be extracted.
Depending on whether or not you know what the contents of your files would be those might be irrelevant limitations, but could also be "deal breakers" if you do not know what the files will contain beforehand - e.g. if coming from external sources.
So the only plausible solution is to "reprint" a file using our Viewer SDK and the Drivers API SDK - this requires the use of two SDK products simultaneously but will be much easier to code and if you only need to get a B&W image for OCR/white space detection purposes it might be sufficient)
In the new SDK that we are developing (for v3 of the Viewer and 5 of the printing drivers) - we will be consolidating all methods - so you would be able to both make modifications to PDF content and create new PDF content working with the same file. You would be able to access a given image, extract and modify it - and then directly replace it in the existing PDF structure without the need of recreating whole pages, but I do not have the eta for the new SDK yet.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi Stefan!
I need the BW conversion only as a separate function, it's not for OCR/white space detection at all.
I need the BW conversion only as a separate function, it's not for OCR/white space detection at all.
Do you mean to export the whole document as an image by "reprinting" a pdf file?So the only plausible solution is to "reprint" a file ...
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Ho Relapse,
Exporting to image can be done with the Viewer SDK only, but will remove any and all text and vector data from the file.
I had in mind to open and start the print process in our Viewer, and output that to our printing drivers - there are down-sample settings that will directly convert the images in the "printed" file to monochrome and you will still keep your vector objects and text as such.
Best,
Stefan
Exporting to image can be done with the Viewer SDK only, but will remove any and all text and vector data from the file.
I had in mind to open and start the print process in our Viewer, and output that to our printing drivers - there are down-sample settings that will directly convert the images in the "printed" file to monochrome and you will still keep your vector objects and text as such.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi Stefan!
Did you mean the printer setting for grayscale (please check my attachment)?
Did you mean the printer setting for grayscale (please check my attachment)?
Could you tell me where is the information for using those printing drivers to find in your manuals? Would I have the PDF format as the output? I think I would, if you're writing of vector objects... and output that to our printing drivers ...
- Attachments
-
- grayscalePrintingSettings.zip
- (122.03 KiB) Downloaded 283 times
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
I had in mind the downsampling options in our printing drivers (as per the attached image) - when you set downsampling for Monochrome images as well - this will also convert all text to Black (or White) colour.
You can control the printing process using the Drivers API SDK:
https://www.pdf-xchange.com/product ... rivers-api
SO you need to open the pdf and start the print process in the Viewer SDK - and then pass the print job to our printer (and control all properties including downsampling and where the new file would be stored).
Hope this is a bit clearer now!
Cheers,
Stefan
I had in mind the downsampling options in our printing drivers (as per the attached image) - when you set downsampling for Monochrome images as well - this will also convert all text to Black (or White) colour.
You can control the printing process using the Drivers API SDK:
https://www.pdf-xchange.com/product ... rivers-api
SO you need to open the pdf and start the print process in the Viewer SDK - and then pass the print job to our printer (and control all properties including downsampling and where the new file would be stored).
Hope this is a bit clearer now!
Cheers,
Stefan
- Attachments
-
- downsampling.zip
- (67.52 KiB) Downloaded 257 times
Re: How to convert a colored document to a monochrome one?
Hi!
I've downloaded and installed the test version of PDF-XChange 5 API.
Then I could use the method void set_Option(string pOptionName , object _p2); of the printer, e.g. printer.set_Option("Color.Convert", 1); for converting all of the document's images and text to grayscale.
Referencing the last quote again, where is then that print job stored which was created by PDF-XChange Viewer SDK, to pass it further to PDF-XChange 5 API, I need an appropriate object. I don't want to disturb the support with such detailed questions, maybe there is a code sample illustrating the interaction of those two modules (PDF-XChange Viewer SDK and PDF-XChange 5 API) relating to this issue?
I've downloaded and installed the test version of PDF-XChange 5 API.
I can do it with the command HRESULT PrintDocument(LONG ID, LONG Flags);... you need to open the pdf and start the print process in the Viewer SDK ...
So I need to instantiate a printer object: object get_Printer(string pServerName, string pPrinterName, string pRegKey, string pDevCode);... and then pass the print job to our printer ...
Then I could use the method void set_Option(string pOptionName , object _p2); of the printer, e.g. printer.set_Option("Color.Convert", 1); for converting all of the document's images and text to grayscale.
Referencing the last quote again, where is then that print job stored which was created by PDF-XChange Viewer SDK, to pass it further to PDF-XChange 5 API, I need an appropriate object. I don't want to disturb the support with such detailed questions, maybe there is a code sample illustrating the interaction of those two modules (PDF-XChange Viewer SDK and PDF-XChange 5 API) relating to this issue?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
Actually - after initializing the new temporary printer - and setting all it's options - you then also need to set it up as the default printer (SetAsDefaultPrinter), then initialize the Viewer print method and start the actual printing, and once the print is complete - restore the default printer to what it was before (RestoreDefaultPrinter).
And thinking of it - if you do have the end user Viewer also installed - you might not need to open the file in the Viewer AX - you might want to try the command line printing option for our Viewer:
For example,
PDFXCView.exe /print c:\mydocument.pdf - this will send a print jog to the default printer with the default end user Viewer Printing settings.
Best,
Stefan
Actually - after initializing the new temporary printer - and setting all it's options - you then also need to set it up as the default printer (SetAsDefaultPrinter), then initialize the Viewer print method and start the actual printing, and once the print is complete - restore the default printer to what it was before (RestoreDefaultPrinter).
And thinking of it - if you do have the end user Viewer also installed - you might not need to open the file in the Viewer AX - you might want to try the command line printing option for our Viewer:
For example,
PDFXCView.exe /print c:\mydocument.pdf - this will send a print jog to the default printer with the default end user Viewer Printing settings.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Step by step it's going to be more understandable for me One more question, how could I set the output of the file to be converted as a pdf file?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
Just take a look at the sample drivers API project. There's already an example how to print .txt/.doc files (The File Print button and the accompanying code) - you can print pdf files the same way.
Best,
Stefan
Just take a look at the sample drivers API project. There's already an example how to print .txt/.doc files (The File Print button and the accompanying code) - you can print pdf files the same way.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi! I've tried to set some printer options in the procedure bFilePrint_Click after defining it as a default printer with the command SetAsDefaultPrinter() but in vain:
I've also got no positive result trying to retrieve the value of a printer option:
I get the exception "ArgumentException was unhandled" (Value does not fall within the expected range) in each case.
P.S. I've printed a colored pdf file (using PDF-XChange Viewer - no SDK!) into a new pdf file converting it to grayscale. It functions! But I founded out that if I open the newly created pdf and try to copy the text into an editor it fails. I get only unknown characters shown. But if I do it with Adobe Acrobat there are two options in the context menu: plain copy (Ctrl+C) and formatted copy. The plain copy leads to the same result as in PDF-XChange Viewer, but the formatted one delivers the correct text. Otherwise the converted images are able to be copied to e.g. Paint.
Code: Select all
PDFPrinter.set_Option("Color.Convert", 1);
Code: Select all
var optionValue = PDFPrinter.get_Option("Paper.LayoutType");
P.S. I've printed a colored pdf file (using PDF-XChange Viewer - no SDK!) into a new pdf file converting it to grayscale. It functions! But I founded out that if I open the newly created pdf and try to copy the text into an editor it fails. I get only unknown characters shown. But if I do it with Adobe Acrobat there are two options in the context menu: plain copy (Ctrl+C) and formatted copy. The plain copy leads to the same result as in PDF-XChange Viewer, but the formatted one delivers the correct text. Otherwise the converted images are able to be copied to e.g. Paint.
Re: How to convert a colored document to a monochrome one?
Sorry, it was a false parameter notification. It should be the following one:
To expand the last thing I addressed in my last message: Is there any possibility to force the formatting of the text to be kept after such a conversion?
Code: Select all
PDFPrinter.Option["Graphics.Color.Convert.Method"] = 1;
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
So the problem with setting the printer colours is now resolved right? And the only outstanding question is for the way the Viewer prints text? I am afraid that it will always print embedded fonts as curves - due to some issues with the printers not having exactly the same font resulting in distorted printout, and there's no way to control this unfortunately.
Best,
Stefan
So the problem with setting the printer colours is now resolved right? And the only outstanding question is for the way the Viewer prints text? I am afraid that it will always print embedded fonts as curves - due to some issues with the printers not having exactly the same font resulting in distorted printout, and there's no way to control this unfortunately.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
But as I've described the situation it's possible to access the text using the option "formated copy" in Acrobat. Maybe there is also such a function in PdfXChange Viewer???
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
Adobe might be using "OCR on the fly" on such text - I can't tell for sure, but our Viewer is definitely not yet capable of extracting such additional text information - and paste it e.g. in Word with all the text formatting intact.
Best,
Stefan
Adobe might be using "OCR on the fly" on such text - I can't tell for sure, but our Viewer is definitely not yet capable of extracting such additional text information - and paste it e.g. in Word with all the text formatting intact.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi! I have then one more theoretical question. In the coming version of the Viewer it will be possible to alter text in an existing PDF file. Will it also be possible to do it with a converted PDF file, where the formatting information of the text isn't complete after the conversion (in this case - after printing it in grayscale)? In such a converted file I can mark the text and copy it, but as I explained it: the formatting information seems to be only partial. Could I then replace the old text with a new one and if I could, would it be possible to do it without loss of formatting (or to express it differently - could I then paste the text so that it receives the format of text in the converted file?
Re: How to convert a colored document to a monochrome one?
And a further question from me: I can't find the proper settings to manage the size of the destination file? I've tried to use the following commands:
but it didn't help me. To illustrate what settings I need I've placed a screen shot of the printer settings mask with the properties marked I'm looking for.
Thanks!
P.S. I've extended the upper commands with the assignment PDFPrinter.Option["Paper.SheetSizeIndex"] = -2; (Value -2 means custom sheet size which is defined by properties SheetWidth and SheetHeight). Nevertheless it doesn't help.
P.P.S. Sorry, it did help but the object itself, that had the size of the whole document page in the original document, became smaller and is placed centered on the new converted document. Some setting is absent. I'll look for it further.
Code: Select all
PDFPrinter.Option["Paper.SheetWidth"] = 1110;
PDFPrinter.Option["Paper.SheetHeight"] = 1110;
Thanks!
P.S. I've extended the upper commands with the assignment PDFPrinter.Option["Paper.SheetSizeIndex"] = -2; (Value -2 means custom sheet size which is defined by properties SheetWidth and SheetHeight). Nevertheless it doesn't help.
P.P.S. Sorry, it did help but the object itself, that had the size of the whole document page in the original document, became smaller and is placed centered on the new converted document. Some setting is absent. I'll look for it further.
- Attachments
-
- undesiredAlteringOfSizeAfterConverting.zip
- (34.5 KiB) Downloaded 247 times
-
- PaperFormat.zip
- (98.99 KiB) Downloaded 247 times
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
On the issue with greyscale converted documents - it will depend on what portion of the text is missing, and what's present. if a font is partially embedded - only the characters that are embedded will be usable - so you won't e.g. be able to type characters that were not present in the original text. Maybe my colleagues from the dev team would be able to comment more, but in any case it will be clear once v3 of the Viewer and the respective SDK is released.
As for the page sizes - please make sure that this "shrinking" is not happening due to e.g. difference in the DPI used?
Best,
Stefan
On the issue with greyscale converted documents - it will depend on what portion of the text is missing, and what's present. if a font is partially embedded - only the characters that are embedded will be usable - so you won't e.g. be able to type characters that were not present in the original text. Maybe my colleagues from the dev team would be able to comment more, but in any case it will be clear once v3 of the Viewer and the respective SDK is released.
As for the page sizes - please make sure that this "shrinking" is not happening due to e.g. difference in the DPI used?
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi, Stefan!
I've read in the js api reference that there are two dpi values to be set in a pdf document: bitmapDPI and gradientDPI. In my test file they have the values of 300 and 150 dpi respective. In the documentation for the driver api I've found the references to dpi values only in the context of Color.Downsample, Indexed.Downsample and MonoAndDrawings.Downsample where the default values (bitmap or gradient?) are actually 96 as per explanation. But I use no downsampling in my test.
P.S. The bitmapDPI and gradientDPI properties of the converted file are also 300 and 150 dpi as of the original file.
These are the assignments I've done in my code:
I've read in the js api reference that there are two dpi values to be set in a pdf document: bitmapDPI and gradientDPI. In my test file they have the values of 300 and 150 dpi respective. In the documentation for the driver api I've found the references to dpi values only in the context of Color.Downsample, Indexed.Downsample and MonoAndDrawings.Downsample where the default values (bitmap or gradient?) are actually 96 as per explanation. But I use no downsampling in my test.
P.S. The bitmapDPI and gradientDPI properties of the converted file are also 300 and 150 dpi as of the original file.
These are the assignments I've done in my code:
Code: Select all
PDFPrinter.Option["Graphics.Color.Convert.Method"] = 1;
//PDFPrinter.Option["Graphics.Color.Downsample.To"] = 300; // has no effect
//PDFPrinter.Option["Graphics.Indexed.Downsample.To"] = 300; // has no effect
//PDFPrinter.Option["Graphics.MonoAndDrawings.Downsample.To"] = 300; // has no effect
PDFPrinter.Option["Graphics.Indexed.Convert.Method"] = 1;
PDFPrinter.Option["Graphics.MonoAndDrawings.Convert.Method"] = 1;
PDFPrinter.Option["Fonts.Subset"] = false;
PDFPrinter.Option["Paper.SheetWidth"] = 1110;
PDFPrinter.Option["Paper.SheetHeight"] = 1110;
PDFPrinter.Option["Paper.SheetSizeIndex"] = -2;
PDFPrinter.Option["Save.SaveType"] = 2;
PDFPrinter.Option["Save.ShowSaveDialog"] = false;
PDFPrinter.Option["Save.File"] = "C:\\xtest.pdf";
PDFPrinter.Option["Save.WhenExists"] = 1;
-
- User
- Posts: 205
- Joined: Fri May 18, 2012 8:41 pm
Re: How to convert a colored document to a monochrome one?
Hi relapse,
Thank you for the code snippet.
Please could you repeat what was your original question?
Thanks.
Sincerely,
Thank you for the code snippet.
Please could you repeat what was your original question?
Thanks.
Sincerely,
Re: How to convert a colored document to a monochrome one?
Hi! Sorry, I was ill last week, and I couldn't post my reply. The original issue was the unwanted size altering of the pdf document after converting it to gray scale using drivers API (I just print the file to be converted into a new pdf file, altering its color). The result object is smaller as the original one. Stefan meant it could be the problem of the DPI difference. I tested it assigning the DPI values explicitly but it had no effect. Could you give me a tip where I should search for the answer?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
We discussed this latest problem in the team - but will need to also speak with one of the guys in the canadina office later this afternoon before I can post any suggestions.
Best,
Stefan
We discussed this latest problem in the team - but will need to also speak with one of the guys in the canadina office later this afternoon before I can post any suggestions.
Best,
Stefan
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
Please try adding: before initiating the printing and see if that will help!
Best,
Stefan
Please try adding:
Code: Select all
PDFPrinter.Option["DevMode.CWidth"] = 1110;
PDFPrinter.Option["DevMode.CHeight"] = 1110;
PDFPrinter.Option["DevMode.CPapSize"] = 256; // DMPAPER_CUSTOM
//then call
PDFPrinter.ApplyOptions(o);
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi! Executing the command I get an ArgumentException that informs me that the value (I guess the value of the argument) is out of range.
Code: Select all
PDFPrinter.Option["DevMode.CPapSize"] = 256;
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
I spent some time reading this article:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
But can't seem to find what the proper value should be there - so I will need to once again discuss this with my colleagues.
We will post an updated reply here as soon as possible.
Best,
Stefan
Tracker
I spent some time reading this article:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
But can't seem to find what the proper value should be there - so I will need to once again discuss this with my colleagues.
We will post an updated reply here as soon as possible.
Best,
Stefan
Tracker
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
The correct line of code is actually: Apologies for this error on our side!
Cheers,
Stefan
The correct line of code is actually:
Code: Select all
PDFPrinter.Option["DevMode.PapSize"] = 256;
Cheers,
Stefan
Re: How to convert a colored document to a monochrome one?
Sorry, I couldn't reply earlier. It seems to have no effect. I place here one more time my code:
PDFPrinter.SetAsDefaultPrinter();
bPXCPrinterDefault = true;
PDFPrinter.Option["Graphics.Color.Convert.Method"] = 1;
PDFPrinter.Option["Graphics.Color.Downsample.To"] = 300;
PDFPrinter.Option["Graphics.Indexed.Downsample.To"] = 300;
PDFPrinter.Option["Graphics.MonoAndDrawings.Downsample.To"] = 300;
PDFPrinter.Option["Graphics.Indexed.Convert.Method"] = 1;
PDFPrinter.Option["Graphics.MonoAndDrawings.Convert.Method"] = 1;
PDFPrinter.Option["Fonts.Subset"] = false;
PDFPrinter.Option["DevMode.PapSize"] = 256; // DMPAPER_CUSTOM
PDFPrinter.Option["Paper.SheetWidth"] = 1000;
PDFPrinter.Option["Paper.SheetHeight"] = 1000;
PDFPrinter.Option["Paper.SheetSizeIndex"] = -2; // otherwise I'll get an A4 page in the exported file
PDFPrinter.Option["Save.SaveType"] = 2;
PDFPrinter.Option["Save.ShowSaveDialog"] = false;
PDFPrinter.Option["Save.File"] = "C:\\xtest.pdf";
PDFPrinter.Option["Save.WhenExists"] = 1;
PDFPrinter.ApplyOptions(0);
System.Diagnostics.Process printJob = new System.Diagnostics.Process();
printJob.StartInfo.FileName = "C:\\pdfs\\sizeTestForGrayScaleConversion.pdf";
printJob.StartInfo.UseShellExecute = true;
printJob.StartInfo.Verb = "print";
printJob.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
printJob.Start();
- Attachments
-
- sizeAlteration.zip
- (23.22 KiB) Downloaded 254 times
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
You are still missing:
Best,
Stefan
You are still missing:
Code: Select all
PDFPrinter.Option["DevMode.CWidth"] = 1000;
PDFPrinter.Option["DevMode.CHeight"] = 1000;
Stefan
Re: How to convert a colored document to a monochrome one?
Hi, Stefan! You are the best as usual. But one more question on the documentation of the PDF-XChange Drivers API, I use the file Books-PDF-XChange-Drivers-API.pdf. I found no reference to the section of DevMode! Why? Is there another documentation for your drivers API?
Thank you very much for your effort!
Thank you very much for your effort!
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
The DevMode structure is described here in full:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
And I will speak with the people maintaining the manuals so that we include a reference to this in the Drivers API Manual.
Best,
Stefan
The DevMode structure is described here in full:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
And I will speak with the people maintaining the manuals so that we include a reference to this in the Drivers API Manual.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi! I have a question: Can I use PDF-XChange 5 API as a full version if I possess a license for PDF-XChange PRO 4 SDK?
P.S. I tested the conversion of a pdf to a grayscale document with the sample project of PDF-XChange 5 API (test version). Now I want to test it with the full version of PDF-XChange PRO 4 SDK, it should be possible as the package includes also PDF-XChange Driver API SDK. I've started the sample project in Program Files\Tracker Software\PDF-XChange PRO 4 SDK\Examples\APIExamples\C#Examples\PDFdriverAPI but the DLL file "PXCComLib" is absent and I can't run the test programm.
P.S. I tested the conversion of a pdf to a grayscale document with the sample project of PDF-XChange 5 API (test version). Now I want to test it with the full version of PDF-XChange PRO 4 SDK, it should be possible as the package includes also PDF-XChange Driver API SDK. I've started the sample project in Program Files\Tracker Software\PDF-XChange PRO 4 SDK\Examples\APIExamples\C#Examples\PDFdriverAPI but the DLL file "PXCComLib" is absent and I can't run the test programm.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
I believe you will need a V5 key. Please send us your current license to support@pdf-xchange.com with a link back to this topic, and we will see if you are eligible for a discounted/free upgrade to V5 of our SDK products.
I had no problems compiling and running the
..\PDF-XChange 5 API\Examples\APIExamples\C#Examples\PDFdriverAPI
sample project - but with a V5 key.
Best,
Stefan
I believe you will need a V5 key. Please send us your current license to support@pdf-xchange.com with a link back to this topic, and we will see if you are eligible for a discounted/free upgrade to V5 of our SDK products.
I had no problems compiling and running the
..\PDF-XChange 5 API\Examples\APIExamples\C#Examples\PDFdriverAPI
sample project - but with a V5 key.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi, Stefan! I've found the missing DLL, but in the sample directory of PDF-XChange 5 API: C:\Program Files\Tracker Software\PDF-XChange 5 API\Examples\Bin\C#\Interop.PXCComLib.dll Why is it absent in the directory of PDF-XChange PRO 4 SDK? I installed that package copmletely with all samples. Could I refer that library?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
V4 of the PRO SDK does not have a compiled C# project - hence the missing Interop.PXCComLib.dll.
As a side note - the file pxccom.tlb is registered by the installer so you should not worry about it at all and no additional copies of it are needed.
Best,
Stefan
V4 of the PRO SDK does not have a compiled C# project - hence the missing Interop.PXCComLib.dll.
As a side note - the file pxccom.tlb is registered by the installer so you should not worry about it at all and no additional copies of it are needed.
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi! I'm trying to print a pdf file grayscaling it. I've achieved it but now I have a new problem trying to extend the present functionality. The new issue is the source and the destination files should be the same one (is it possible at all or should I use a temporary copy of the source file?) and should have the .tmp file extension. How can I start a print job without opening the PDF viewing application, because if I do it I get an exception saying there is no application linked with such a file type?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
You'd best use a temporary copy of the source file.
You should be able to print through the command line - and this should not launch the Viewer's UI:
<<path to>>\PDFXCview.exe /print c:\mydocument.pdf
Best,
Stefan
You'd best use a temporary copy of the source file.
You should be able to print through the command line - and this should not launch the Viewer's UI:
<<path to>>\PDFXCview.exe /print c:\mydocument.pdf
Best,
Stefan
Re: How to convert a colored document to a monochrome one?
Hi, Stefan! Thanks for your quick reply! If I don't want to have a viewer .exe in my application directory, could I print a loaded document to a temporary file with the viewer library? If I could, then I need a possibility to define the destination file, but I haven't found any for the PrintDocument method.
- Ivan - Tracker Software
- Site Admin
- Posts: 3549
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: How to convert a colored document to a monochrome one?
If you don't have PXCComLib type library registered, please try to run:
at the location where pdfSaver5.exe is installed on your machine.
Code: Select all
pdfSaver5.exe /RegServer
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Re: How to convert a colored document to a monochrome one?
Hi! I surely can print a loaded file using the command (related to my last message) where the second parameter disables the user interface e.g. the save dialog. The destination file is to be defined as follows: And if you want to suppress an application opening the printed/converted file you should use the following printer setting:
Code: Select all
pdfViewer.PrintDocument(_documentId, PXCVA_Flags.PXCVA_NoUI);
Code: Select all
PDFPrinter.Option["Save.File"] = _tempPrintFileForGraycaleConversion; // it's a string
Code: Select all
PDFPrinter.Option["Save.RunApp"] = false;
- John - Tracker Supp
- Site Admin
- Posts: 5219
- Joined: Tue Jun 29, 2004 10:34 am
- Location: United Kingdom
- Contact:
Re: How to convert a colored document to a monochrome one?
So relapse is this now resolved or is more required from us ?
Thanks
Thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
Re: How to convert a colored document to a monochrome one?
Hi! I've recently tested my program only with an A4 document, it functions perfectly, but now testing it with documents of other sizes I discovered again that I have the problem as the converted document has other size as I set it in my source code. I'm at a loss now as it's functioned already perfectly. I suppose the A4 format is used as the size for the default printer. Here is my code:
I can't get it where is the size of A4 format coming from? The snapshot with the printing result is in the attachment to find.
Thanks for your replies!
P.S. I'm really irritated: I've tried the settings I use above in the PDFPrinter.Option code block with your sample application from the PDF-XChange 5 API and it functions. It seems that the command pdfViewer.PrintDocument(_documentId, 2); doesn't take the settings I've done to the default printer before. Why?
Code: Select all
private void GrayscaleConversion()
{
const int decimalFactor = 10;
PDFPrinter.SetAsDefaultPrinter();
bPXCPrinterDefault = true;
PDFPrinter.Option["Graphics.Color.Convert.Method"] = 1;
PDFPrinter.Option["Graphics.Color.Downsample.To"] = 300;
PDFPrinter.Option["Graphics.Indexed.Downsample.To"] = 300;
PDFPrinter.Option["Graphics.MonoAndDrawings.Downsample.To"] = 300;
PDFPrinter.Option["Graphics.Indexed.Convert.Method"] = 1;
PDFPrinter.Option["Graphics.MonoAndDrawings.Convert.Method"] = 1;
PDFPrinter.Option["Fonts.Subset"] = false;
PDFPrinter.Option["DevMode.PapSize"] = 256;
PDFPrinter.Option["DevMode.CWidth"] = CurrentWidthInMm * decimalFactor;
PDFPrinter.Option["DevMode.CHeight"] = CurrentHeightInMm * decimalFactor;
PDFPrinter.Option["Paper.SheetWidth"] = CurrentWidthInMm * decimalFactor;
PDFPrinter.Option["Paper.SheetHeight"] = CurrentHeightInMm * decimalFactor;
PDFPrinter.Option["Paper.SheetSizeIndex"] = -2;
PDFPrinter.Option["Save.SaveType"] = 2;
PDFPrinter.Option["Save.ShowSaveDialog"] = false;
PDFPrinter.Option["Save.File"] = _tempPrintFileForGrayscaleConversion;
PDFPrinter.Option["Save.WhenExists"] = 1;
PDFPrinter.Option["Save.RunApp"] = false;
PDFPrinter.ApplyOptions(0);
pdfViewer.PrintDocument(_documentId, 2);
if (bPXCPrinterDefault)
{
PDFPrinter.RestoreDefaultPrinter();
bPXCPrinterDefault = false;
}
}
Thanks for your replies!
P.S. I'm really irritated: I've tried the settings I use above in the PDFPrinter.Option code block with your sample application from the PDF-XChange 5 API and it functions. It seems that the command pdfViewer.PrintDocument(_documentId, 2); doesn't take the settings I've done to the default printer before. Why?
- Attachments
-
- grayscalePrintingIntoAFile.zip
- (30.83 KiB) Downloaded 245 times
- Tracker Supp-Stefan
- Site Admin
- Posts: 17824
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to convert a colored document to a monochrome one?
Hi Relapse,
You will also need to set up the Viewer printing preferences - please check section 2.2.2.14 Print of the Viewer AX manual.
Best,
Stefan
You will also need to set up the Viewer printing preferences - please check section 2.2.2.14 Print of the Viewer AX manual.
Best,
Stefan