We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set the StripOffsets while converting the Pdf to multipage Tif

Hi,

We are converting the pdf to multipage tif using ASPOSE PDF java API. Some of the generated tf files are not acceptable by our legacy image processing back end systems while others are . we are using the same conversion process from pdf to multipage tif .When we try to look at the tag information for the sucessfully processed ones vs not successful ones below is the difference found. Though both the tifs are generated by ASPOSE PDF java API, it is setting StripOffsets to Long for some tifs and short for others. I need a way to set the StripOffSets to long during conversion inorder to be able to process any tif successfully. Can you please suggest how to set the StripOffsets?

Note: the issue is only with processing the first page of the tif

Tif successufully processed by backend (GOOD)
Page 1
ImageWidth (1 Short): 2550
ImageLength (1 Short): 3300
BitsPerSample (1 Short): 1
Compression (1 Short): Group 4 Fax (aka CCITT FAX4)
Photometric (1 Short): MinIsWhite
StripOffsets (132 Long): 170, 174, 178, 182, 186, 247, 269, 317, 416,…
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Short): 25
StripByteCounts (132 Short): 4, 4, 4, 4, 61, 22, 48, 99, 449, 710, 437,…
XResolution (1 Rational): 300
YResolution (1 Rational): 300
ResolutionUnit (1 Short): Inch
Predictor (1 Short): 1

Page 2
ImageWidth (1 Short): 2550
ImageLength (1 Short): 3300
BitsPerSample (1 Short): 1
Compression (1 Short): Group 4 Fax (aka CCITT FAX4)
Photometric (1 Short): MinIsWhite
StripOffsets (132 Long): 110798, 110802, 110806, 110810, 110814,…
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Short): 25
StripByteCounts (132 Short): 4, 4, 4, 4, 219, 1106, 2926, 10, 1688, 1134,…
XResolution (1 Rational): 300
YResolution (1 Rational): 300
ResolutionUnit (1 Short): Inch
Predictor (1 Short): 1

Tif not successuful at backend (BAD)
Page 1
ImageWidth (1 Short): 2550
ImageLength (1 Short): 3300
BitsPerSample (1 Short): 1
Compression (1 Short): Group 4 Fax (aka CCITT FAX4)
Photometric (1 Short): MinIsWhite
StripOffsets (132 Short): 170, 174, 178, 182, 186, 190, 239, 314, 400,…
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Short): 25
StripByteCounts (132 Short): 4, 4, 4, 4, 4, 49, 75, 86, 1069, 794, 457,…
XResolution (1 Rational): 300
YResolution (1 Rational): 300
ResolutionUnit (1 Short): Inch
Predictor (1 Short): 1

Page 2
ImageWidth (1 Short): 2550
ImageLength (1 Short): 3300
BitsPerSample (1 Short): 1
Compression (1 Short): Group 4 Fax (aka CCITT FAX4)
Photometric (1 Short): MinIsWhite
StripOffsets (132 Long): 65278, 65282, 65286, 65290, 65294, 65298,…
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Short): 25
StripByteCounts (132 Short): 4, 4, 4, 4, 4, 48, 371, 3712, 775, 1015,…
XResolution (1 Rational): 300
YResolution (1 Rational): 300
ResolutionUnit (1 Short): Inch
Predictor (1 Short): 1

@klingareddy,

Can you please share source files along with sample code to further investigate this issue on our end.

TSP-21-G.pdf (198.4 KB)
Here is the code that we are using for the coversion.I have attached the file that is succesfully converted the stripOffSets to long as required. Unfortunately i cann’t upload the file which is bad (due to secutiry reasons )…but you should be able to let me know with the below code that how to set the stripOffSets during conversion ?

try (OutputStream imageStream = new ByteArrayOutputStream()) {
		
		setPdfLicense();

		IDocument pdfDocument = new com.aspose.pdf.Document(inputStream);
		
		//Create ResolutionObject
		Resolution resolution=new Resolution(300);
		
		TiffSettings tiffSettings=new TiffSettings();
		
		//Set the Compression of resultant TIFF image.
		tiffSettings.setCompression(CompressionType.CCITT4);
		
		//Set Color depth of resultant Image.
		tiffSettings.setDepth(ColorDepth.Format8bpp);
		
		//Create TiffDevice Object with particular resolution.
		TiffDevice tiffDevice=new TiffDevice(resolution,tiffSettings);
		
		//Convert all pages of pdf file to tif format.
		tiffDevice.process(pdfDocument, imageStream);

		return imageStream;
    } catch (Exception e) {
		throw new ServletException(e);
    } finally {
		debugMsg.append("\n"+Utility.getCallTime(Kickoff)+"\n");

    }

@klingareddy

Thanks for sharing further information.

Regretfully there is no method or property in the API to set StripOffsets and an enhancement ticket has already been logged in our issue tracking system for .NET API (PDFNET-47096). We will also log it for Java but, we need sample PDFs from which problematic TIFFs are being generated at your side.

If you cannot share files publicly, you can share them in a private message by clicking over the username and pressing the Blue Message button. We assure you that only Aspose Staff will have access to those files and they will not be disclosed to anyone. We also remove them from our system once investigation is complete.