Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

whitelilne appeared in the exported pdf to png

Community Beginner ,
Dec 08, 2017 Dec 08, 2017

Hi,

I have a script to export PDF to PNG. While exporting the PNG the png is exported and a thin line appeared in the output as well as text blured.

Is there any way to overcome the hairline and text blur.

app.preferences.rulerUnits = Units.PIXELS;

app.displayDialogs = DialogModes.NO;

var fileRef = new File("D:/Cover/settings.csf");

loadColorSettings(fileRef);

fileRef = new File("D:/Cover/input.pdf");

var pdfOpenOptions = new PDFOpenOptions();

var resolution = 72;

pdfOpenOptions.antiAlias = true;

pdfOpenOptions.mode = OpenDocumentMode.RGB;

pdfOpenOptions.resolution = resolution;

pdfOpenOptions.page = 1;

pdfOpenOptions.cropPage = CropToType.BLEEDBOX;

pdfOpenOptions.constrainProportions = false;

pdfOpenOptions.bitsPerChannel = BitsPerChannelType.EIGHT;

var outerBorderColor = new SolidColor();

outerBorderColor.rgb.red = 0;

outerBorderColor.rgb.green = 0;

outerBorderColor.rgb.blue = 0;

var saveOptions = new ExportOptionsSaveForWeb();

saveOptions.format = SaveDocumentType.PNG;

saveOptions.PNG8 = false;

saveOptions.quality = 60;

saveOptions.blur = 0.0;

saveOptions.includeProfile = true;

saveOptions.embedColorProfile = true;

saveOptions.interlaced = false;

saveOptions.optimized = true;

saveOptions.colorConversion = false;

var doc = app.open(fileRef, pdfOpenOptions);

doc.trim(TrimType.BOTTOMRIGHT, true, false, true, false);

var docwidth = doc.width;

var docheight = doc.height;

doc.resizeImage(docwidth,docheight,resolution,ResampleMethod.BICUBIC);

app.displayDialogs = DialogModes.ERROR;

doc.flatten();

doc.selection.selectAll();

var saveFile = new File("D:/Cover/output.png");

doc.exportDocument(saveFile,ExportType.SAVEFORWEB,saveOptions);

doc.close(SaveOptions.DONOTSAVECHANGES);

app.displayDialogs = DialogModes.ERROR;

function loadColorSettings(file)

{

    var desc = new ActionDescriptor();

    var ref = new ActionReference();

    ref.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID('colorSettings') );

    ref.putEnumerated( charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

    desc.putReference( charIDToTypeID('null'), ref );

    var fileDesc = new ActionDescriptor();

    fileDesc.putPath( charIDToTypeID('Usng'), file );

    desc.putObject( charIDToTypeID('T   '), stringIDToTypeID('colorSettings'), fileDesc );

    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );

}

Thanks

Jayaraj

TOPICS
Actions and scripting
694
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
People's Champ ,
Dec 08, 2017 Dec 08, 2017

But why not use this method instead of doc.exportDocument() ?

var png_options = new PNGSaveOptions();

with (png_options)

    {

    compression = 9;

    interlaced = false;

    }

//app.displayDialogs = DialogModes.NO;

doc.saveAs(saveFile, png_options);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2017 Dec 14, 2017

Yes, I did but the issue is the text uses drop shadowed and as a result it reflect in CS6 versions either PDF/Photoshop. How to supress the white line which is not appeared in earlier version and having the issue in CS6

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 15, 2017 Dec 15, 2017

Could you provide a simple PSD or screenshot to understand what's going on?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 15, 2017 Dec 15, 2017

I have attached screenshot and the thin line around the text "Clinical Practice" and the bottom of the text highlighted in red. I cross checked pitstop and investigated that this might be occured due to the drop shadowed texted textframe. This is pdf document exported from Indesign document. As I am new to this forum not able to attach pdf for your understanding.

screenshot.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 15, 2017 Dec 15, 2017

OK. You can download the PDF to GoogleDrive or another file sharing service and post link here.

P.S. I've never worked with PDF, but I'll try to figure it out. )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2017 Dec 15, 2017
LATEST

the meat of your script seems to be

  1. var doc = app.open(fileRef, pdfOpenOptions);  
  2. doc.trim(TrimType.BOTTOMRIGHT, true, false, true, false);  
  3. var docwidth = doc.width;  
  4. var docheight = doc.height;  
  5. doc.resizeImage(docwidth,docheight,resolution,ResampleMethod.BICUBIC);  
  6. app.displayDialogs = DialogModes.ERROR;  
  7. doc.flatten();  
  8. doc.selection.selectAll();  
  9. var saveFile = new File("D:/Cover/output.png");  
  10. doc.exportDocument(saveFile,ExportType.SAVEFORWEB,saveOptions);  
  11. doc.close(SaveOptions.DONOTSAVECHANGES);

Open page 1 of your pdf.  This will open a new document with a single raster layer that may or may not contain transparency.

Trim the top and bottom of the page using the bottom right pixel

get new width which should not have changed

get new height which may have changed

resize to same size changing the doc resolution to 72.

dialog mode to error

flatten this is where you may be getting your white any transparent area would be filled with a white background color. If the trim did and antialiasing feathering to the top and botton edges some white may have been flatten into pixels less then 100% opaque. Try commenting out the flatten....

select all not needed

save a png that has no transparency because the document has been flatten to a background layer.

close

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines