Evalution Question


#1

Hello,



We are currently evaluating Aspose.PDF.Kit. We are using it primarily
to print generated PDF files. About 50% of the time the printouts are
fine and the other 50% they are gibberish. Could someone tell me if
this has something to do with the software being an evaluation version?



Thank you.


#2

Hi,

Thank you for considering Aspose.

Can you please provide the files that can reproduce the error to us?


#3

Hi,



Thanks for your response.



This is the code we are using to evaluate the tool. I think was taken
right out your documentation. Just by way of background - for this test
we are printing the exact same file each time.



Thanks for your help.



protected void printPdfFile()

throws PrinterException

{

//Shouldn’t need this since all Print Jobs are sitting in a queue?

//if (printingLocks != 0) { return; }



//adds a print lock to ensure only a pdf file to print.

printingLocks++;



boolean canceled = false;



//sets the default print scale - false.

pdfviewer.enableScalePrint(false);



//gets a printjob object.

PrinterJob printJob = PrinterJob.getPrinterJob();



//creates a new PageFormat instance and sets it

//to a default size and orientation.

PageFormat pf = printJob.defaultPage();



//sets PageOrientation to best use page layout.

int orientation =
pdfviewer.getPdfWidth() < pdfviewer.getPdfHeight() ?
PageFormat.PORTRAIT : PageFormat.LANDSCAPE;

pf.setOrientation(orientation);



Paper paper = new Paper();



//A4 bordless

//paper.setSize(595, 842);

//paper.setImageableArea(0, 0, 595, 842);

//

//A5

//paper.setSize(297, 421);

//paper.setImageableArea(23,23,254,378);



//A4

paper.setSize(595, 842);

paper.setImageableArea(43, 43, 509, 756);



//sets the Paper object for this PageFormat.

pf.setPaper(paper);



//sets the start page for printing,

//and you can change it according to

//your request but make sure

//1 =< startPage <= endPage <= pdfviewer.getPdfFilePageCount().

int startPage = 1;



//sets the end page for printing,

//and you can change it according to

//your request but make sure

//1 =< startPage <= endPage <= pdfviewer.getPdfFilePageCount().

int endPage = pdfviewer.getPdfFilePageCount();



//sets the page range according to the user’s decision.

pdfviewer.setPrintPageRange(startPage,endPage);



//sets the page format for each page between startPage and endPage.

for(int page = startPage; page > endPage + 1; page++)

pdfviewer.setPageFormat(page,pf);



//queries document for the number
of pages and the PageFormat and Printable for each page held in the
Pageable instance, document.

printJob.setPageable(pdfviewer);



//prints a set of pages.

printJob.print();



//if problems, reports any errors.

if (!canceled && !pdfviewer.isPrintSuccess())

throw new PrinterException(

    "Problems encountered printing.\n

" +

pdfviewer.getPrintFailureMessage());



printingLocks–;

}


#4

OK. We will check this problem. Can you please also provide the pdf document that can reproduce the error?


#5

Here is a copy of the type of PDF that is causing trouble. We have
determined that the files with trouble are files that were converted
from HTML. However, the same files do print fine from within the Adobe
Reader.


#6

Hi,

Thank you for considering Aspose.

The problem is irrelevant to the evaluation version. We have the example of samplePdfViewer in Aspose.PDF.Kit. If you can view the pdf file in that example correctly, you also can print the pdf file exactly. If you can not view the pdf file or not correct, it is a bug. After all the pdf specification is very large, we cannot complete the whole function. In the latest released version we support the 85% function of pdf specification version 1.6. If you can send the test pdf file, we will imporve the Aspose.PDF.Kit in the next version very soon.